/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package morenoapp.components.thinkgraph.node;

import edu.umd.cs.piccolo.PNode;
import edu.umd.cs.piccolo.nodes.PPath;
import morenoapp.components.thinkgraph.model.DisplayFilter;
import morenoapp.components.thinkgraph.model.DisplayFilterListener;

/**
 *
 * @author root
 */
public class BullEyeTargetNode extends PNode {
    DisplayFilter filter;
    int distance = 100;
    int ringsCount = 3;


    public BullEyeTargetNode(DisplayFilter _filter) {
        super();
        this.filter = _filter;
        this.filter.addDisplayFilterLisneter(new DisplayFilterListener() {
            public void onDisplayFilterChanged() {
                System.out.println("bull eye redraw");
                setDistance(filter.getRingStep());
            }
        });

        distance = filter.getRingStep();
        applyChagnes();
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int _distance) {
        if(this.distance!=_distance){
            this.distance = _distance;
            applyChagnes();
        }
    }

    public int getRingsCount() {
        return ringsCount;
    }

//    public void setRingsCount(int ringsCount) {
//        this.ringsCount = ringsCount;
//    }

    protected void applyChagnes(){
        removeAllChildren();

        for(int i=ringsCount;i>0;i--){
            int diameter = 2*distance*i;
            PNode round = PPath.createEllipse(-diameter/2, -diameter/2, diameter, diameter);
            //round.setPickable(getPickable());
            round.setPaint(null);
            addChild(round);
        }
    }

}
